package com.y.lintcode;

import java.util.Arrays;

/**
 * @author Y2014188432
 * 字符串翻转
 */
public class Test5 {
    public static void main(String[] args) {
        char[] str = {'a','b','c','d','e','f','g'};
        int offset = 3;
        // 处理 offset
        while (offset > str.length){
            offset -= str.length;
        }
        for (int i = str.length - offset; i < str.length; i++) {
            char temp = str[i];
            int j = i;
            // 循环
            while (j + str.length - offset != i){
                str[j] = str[j - 1];
                System.out.println(Arrays.toString(str));
                j --;
            }
            str[i-(str.length - offset)] = temp;
        }
        System.out.println(Arrays.toString(str));
    }
}
